#include <bits/stdc++.h>

using namespace std;

typedef long long ll;

#define in read()
#define pii pair<int,int>
#define fi first
#define se second
#define mes(x) memset(x,0,sizeof(x))
#define pb push_back

const int MAXS = (1<<8)+10;
	
int n,nu[10];
ll P,dp[MAXS][MAXS],f[MAXS][MAXS],g[MAXS][MAXS],ans;

vector <int> al[510];

void add(int x){
	int res = 0;
	for(int i = 0;i < 8;i++)
		while(x % nu[i] == 0) res|=1<<i,x/=nu[i];
	al[x].pb(res);
}

void upd(ll &x,ll y){x = (x+y)%P;}

int main (){
	nu[0] = 2,nu[1] = 3,nu[2] = 5,nu[3] = 7,nu[4] = 11,nu[5] = 13,nu[6] = 17,nu[7] = 19;
	scanf("%d %lld",&n,&P);
	for(int i = 2;i <= n;i++) add(i);
	dp[0][0] = 1;
	if(al[1].size()){
		for(int j = 0;j < al[1].size();j++){
			memcpy(f,dp,sizeof(f));
			memcpy(g,dp,sizeof(g));
			int x = al[1][j];
			for(int s1 = (1<<8)-1;s1 >= 0;s1--)
				for(int s2 = (1<<8)-1;s2 >= 0;s2--){
					if(s1 & s2) continue;
					if(!((s1 | x) & s2))upd(f[s1|x][s2],f[s1][s2]);
					if(!((s2 | x) & s1))upd(g[s1][s2|x],g[s1][s2]);
				}
			for(int s1 = 0;s1 < 1<<8;s1++)
				for(int s2 = 0;s2 < 1<<8;s2++)
					if(!(s1&s2)) dp[s1][s2] = ((f[s1][s2] + g[s1][s2] - dp[s1][s2]) % P + P) % P;
		}
	}
	for(int i = 2;i <= 500;i++)
		if(al[i].size()){
			memcpy(f,dp,sizeof(f));
			memcpy(g,dp,sizeof(g));
			for(int j = 0;j < al[i].size();j++){
				int x = al[i][j];
				for(int s1 = (1<<8)-1;s1 >= 0;s1--)
					for(int s2 = (1<<8)-1;s2 >= 0;s2--){
						if(s1 & s2) continue;
						if(!((s1 | x) & s2))upd(f[s1|x][s2],f[s1][s2]);
						if(!((s2 | x) & s1))upd(g[s1][s2|x],g[s1][s2]);
					}
			}
			for(int s1 = 0;s1 < 1<<8;s1++)
				for(int s2 = 0;s2 < 1<<8;s2++)
					if(!(s1&s2)) dp[s1][s2] = ((f[s1][s2] + g[s1][s2] - dp[s1][s2]) % P + P) % P;
		}
	for(int i = 0;i < 1<<8;i++)
		for(int j = 0;j < 1<<8;j++)
			if((i & j) == 0) upd(ans,dp[i][j]);
	printf("%lld\n",ans);
	return 0;
}
